package com.aliwo.design2.singleton;

/**
 * 单例模式 懒汉模式 线程安全 同步方法.
 *
 * @author Xu Yayuan
 * @date 2022/5/5
 */
public class SingletonDemo02 {
    private SingletonDemo02(){}

    private static SingletonDemo02 instance;

    private synchronized static SingletonDemo02 getInstance() {
        if (null != instance) {
            return instance;
        }
        instance = new SingletonDemo02();
        return instance;
    }

}
